<!--
 * @Author: weisheng
 * @Date: 2021-12-22 15:19:08
 * @LastEditTime: 2023-09-03 16:30:20
 * @LastEditors: weisheng
 * @Description:
 * @FilePath: \wot-starter\src\pages\mine\Mine.vue
 * 记得注释
-->
<template>
  <view>
    <wd-message-box></wd-message-box>
    <wd-toast></wd-toast>
    <view class="mine">
      <!--      <view class="tools">-->
      <!--        <wd-icon name="scan" size="48rpx" color="#292C39" @click="doScan"></wd-icon>-->
      <!--        <wd-icon name="setting" size="48rpx" color="#292C39"></wd-icon>-->
      <!--      </view>-->
      <view class="headerheight"></view>
      <view class="header">
        <view class="header-user">
          <image src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg" class="header-user-avatar"></image>
          <view class="header-user-nickname">
            <view class="nickname">杨子🧑‍💻</view>
            <view class="info">新疆项目</view>
          </view>
        </view>
        <view class="header-target">
          <view class="header-target-item" v-for="(item, key) of target" :key="key">
            <text class="label">{{ item }}</text>
            <text class="value">{{ key }}</text>
          </view>
        </view>
      </view>
      <view class="main">
        <wd-cell-group border>
          <wd-cell title="登记" value="发送票单" is-link icon="evaluation" />
          <wd-cell title="记录" value="查看票单记录" is-link icon="evaluation" />
        </wd-cell-group>
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { useMessage, useNotify } from 'wot-design-uni'
import { useToast } from 'wot-design-uni'
const { showNotify } = useNotify()

const toast = useToast()
const message = useMessage()

const safeHeight = ref<number>(44)

const { userInfo } = storeToRefs(useAuthStore()) // 解构pinia的store
const router = useRouter()
const target = ref<Record<string, number>>({
  运送数: 99,
  票单数: 99
})

/**
 * 扫码
 */
function doScan() {
  uni.scanCode({
    success: (res) => {
      // 扫码内容
      const code: string = res.result || ''
      toast.show(`扫码内容：${code}`)
    }
  })
}

/**
 * 登出
 */
function doLogout() {
  message
    .confirm({ title: '提示', msg: '确认退出当前登录账号吗？' })
    .then(() => {
      // 点击的确认按钮
      useAuthStore().logout()
      router.replaceAll({ name: 'login' })
    })
    .catch((error) => {
      console.log(error)
    })
}
</script>

<style lang="scss" scoped></style>
